home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1992 August
/
info-mac-1992.iso
/
Source
/
3D GrafSys
/
GrafSys.rel
/
Demo Sources
/
squaredance.p
< prev
next >
Wrap
Text File
|
1992-04-25
|
3KB
|
119 lines
program TestGrafSys;
{ 3d GrafSys Demo Program}
{ Vers. 1.1 }
{ (c) 1992 by Christian Franz }
{ This program demonstates the use of the grafsys for simple animation using }
{ the fDrawObject and free rotation command }
{ It also demonstrates the use of AddPoint and AddLine routines for building }
{ 3D objects }
uses
Grafsys, Screen3D;
const
theWindowID = 400;
degree = 0.01745329; (* π/180 *)
var
theWindow: WindowPtr;
theInt: INTEGER;
thePort: Graf3DPtr;
theMaster: Graf3DPtr;
Pyramid, Cube, xFighter: GrafObjPtr;
theEvent: EventRecord;
dx, dy, dz: integer;
r: Rect;
p1, p2: Vector4;
sign: integer;
procedure makesquare (var Obj: GrafObjPtr);
var
OK: Boolean;
c: INTEGER;
begin
Obj := NewObject;
OK := AddPoint(Obj, 100, 100, 0, c);
OK := AddPoint(Obj, -100, 100, 0, c);
OK := AddPoint(Obj, -100, -100, 0, c);
OK := AddPoint(Obj, 100, -100, 0, c);
OK := AddLine(Obj, 1, 2);
OK := AddLine(Obj, 2, 3);
OK := AddLine(Obj, 3, 4);
OK := AddLine(Obj, 4, 1);
end;
procedure getmouserot (var dx, dy, dz: integer);
var
thePoint: point;
begin
GetMouse(thePoint);
dx := 0;
dy := 0;
dz := 0;
if (thePoint.h < thePort^.center.h) and (thePoint.v < thePort^.center.v) then (* mouse in quadrant 1 -> xrot*)
begin
dx := 5;
end;
if (thePoint.h > thePort^.center.h) and (thePoint.v < thePort^.center.v) then (* mouse in quadrant 2 -> yrot*)
begin
dy := 5;
end;
if (thePoint.h > thePort^.center.h) and (thePoint.v > thePort^.center.v) then (* mouse in quadrant 3 -> zrot*)
begin
dz := 5;
end;
if (thePoint.h < thePort^.center.h) and (thePoint.v > thePort^.center.v) then (* mouse in quadrant 4 -> idle*)
begin
end;
if button then
begin
dx := -dx;
dy := -dy;
dz := -dz;
end;
end;
begin
theWindow := GetNewWindow(theWindowID, nil, Pointer(-1));
SetPort(theWindow); (* draw in this window *)
{PenMode(patXOR);}
MoveTo(10, 10);
DrawString('3D Grafiksystem. Object: Square. (C) 1991 by C Franz.');
InitGrafSys;
NewGrafport(theWindow^.portRect, thePort);
MoveTo(10, thePort^.bottom - 0);
DrawString(' Press Button to Exit');
MakeSquare(cube);
SetEye(False, 0, 0, 0, 0, 0, 0, 1.512, FALSE);
ObjFreeTranslate(cube, 0, 0, 500);
ObjRotate(cube, 0 * degree, 0 * degree, 0);
ObjScale(cube, 1, 1, 1);
SetAutoErase(cube, True);
p1[1] := 0;
p1[2] := 0;
p1[3] := 400;
p2[1] := 0;
p2[2] := 200;
p2[3] := 400;
p1[4] := 1;
p2[4] := 1;
sign := 1;
fDrawObject(cube);
repeat
fDrawObject(cube);
ObjRotateArb(cube, p1, p2, 2 * degree); (* although locally done has global effect *)
ObjRotate(cube, 0, -8 * degree, 0);
until Button;
end.